package com.fmyexample.mcsecurityboot.modular.controller;

import com.fmyexample.mcsecurityboot.config.security.CuUserDetails;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mr.fmy
 * @version 1.0.0
 * @ClassName DemoController
 * @Description TODO Demo Controller
 * @createTime 2020/4/15 13:35
 */
@RestController
public class DemoController {

    @GetMapping("/hello")
    public String hello() {
        return "User Hello";
    }

    @GetMapping("/auth/user-info")
    public CuUserDetails userInfo() {
        return (CuUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }
}
